
Imports System.Xml
Imports System.Web
Imports System.Data.Odbc

Public Class siteIndex
    Inherits System.Web.UI.Page

    Dim USERID, sTDUserID As String
    Dim SchemaNM As String = ConfigurationSettings.AppSettings("Environment")
    'Dim SchemaNM As String = "P"
    'Private objTDCall = New GetData
    Dim Enviro As String = SchemaNM
    'Dim GMRUtil As New GMRUtility
    'Dim strDB As String = GMRUtil.GetDBName()
    Dim strTDError As String = ""
    Public intGMRUsers As Integer
    Dim FromDate As String
    Dim ToDate As String
    Dim strDateWhere As String
    Dim strDisplayRange As String
    'Dim objFmt As New FormatData
    'Dim ScreenID As Integer = objFmt.PageMatrix.ondemandstat

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents Table1 As System.Web.UI.WebControls.Table
    Protected WithEvents lblDate As System.Web.UI.WebControls.Label
    Protected WithEvents lblTimestamp As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        '    Dim dataReader As OdbcDataReader
        '    Dim strSQL As String = ""
        '    Dim strSQLa As String = ""
        '    Dim Ds As New DataSet
        '    Dim intCount As Integer = 1

        '    Dim rowCNT As Integer = 0
        '    Dim colCNT As Integer = 0

        '    Dim tmpDate1 As String = Request("ex1")
        '    Dim tmpDate2 As String = Request("ex2")
        '    strDisplayRange = "[" & tmpDate1 & " to " & tmpDate2 & "]"
        '    Dim arrDate1 As Array = Split(tmpDate1, "/")
        '    Dim arrDate2 As Array = Split(tmpDate2, "/")

        '    RunProgressBar("Usage Statistics From " & tmpDate1 & " To " & tmpDate2)

        '    Try
        '        lblDate.Text = strDisplayRange
        '        If SchemaNM = "D" Then
        '            lblTimestamp.Text = Now & " - Dev"
        '        Else
        '            lblTimestamp.Text = Now
        '        End If

        '        tmpDate1 = arrDate1(2) & "-" & PadDate(arrDate1(0)) & "-" & PadDate(arrDate1(1))
        '        tmpDate2 = arrDate2(2) & "-" & PadDate(arrDate2(0)) & "-" & PadDate(arrDate2(1))

        '        FromDate = tmpDate1 & " 00:00:00.000000"
        '        ToDate = tmpDate2 & " 23:59:59.999999"
        '        strDateWhere = "Where Activity_ts Between '" & FromDate & "' and '" & ToDate & "' "

        '        USERID = UCase(Session("USER_ID"))
        '        'sTDUserID = objFmt.GetDTUserID(ScreenID.ToString, "115")

        '        strSQLa = "Select Count(Distinct GMR_USER_ID) As intCount "
        '        strSQLa += "From " & strDB & ".GMR_ACTIVITY_LOG_V "
        '        strSQLa += strDateWhere
        '        objTDCall.CallTD(SchemaNM, sTDUserID, strSQLa, "TB", strTDError, Ds)
        '        intGMRUsers = Ds.Tables(0).Rows(0).Item(0)
        '        Ds = Nothing

        '        strSQL = "SELECT * FROM " & strDB & ".GMR_VIEWS_V  Where View_Nbr < 7 Order By View_Nbr"

        '        USERID = Session("USER_ID")
        '        GMRUtil.SetUserID = sTDUserID
        '        ''sTDUserID = Session("TDUSER_ID")
        '        dataReader = objTDCall.drData(SchemaNM, sTDUserID, strSQL, strTDError)


        '        With Table1
        '            .GridLines = GridLines.Both
        '            .Rows.Add(New TableRow)
        '            rowCNT = Table1.Rows.Count - 1

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "View"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Unique Users"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Displays"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Drill Down"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Sort"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Export"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center

        '            .Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            .Rows(rowCNT).Cells(colCNT).Text = "Print"
        '            .Rows(rowCNT).Cells(colCNT).CssClass = "tblhead2"
        '            .Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center
        '        End With

        '        Do While dataReader.Read
        '            Table1.Rows.Add(New TableRow)
        '            rowCNT = Table1.Rows.Count - 1
        '            Table1.Rows(rowCNT).Cells.Add(New TableCell)
        '            colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '            Table1.Rows(rowCNT).Cells(colCNT).Text = dataReader.GetValue(1)
        '            Table1.Rows(rowCNT).Cells(colCNT).CssClass = "msg5b"
        '            UniqueUsers(Table1, dataReader.GetValue(0))
        '            BuildValueColumns(Table1, dataReader.GetValue(0))
        '            intCount += 1
        '        Loop

        '        dataReader.Close()
        '        'Insert Trureciepts
        '        Add_New_Row("True Receipts Popup")
        '        Add_Cell("N/A")
        '        Add_Cell("<span style='color:black'>* " & fnPopValue() & "</span>")
        '        Add_Cell("N/A")
        '        Add_Cell("N/A")
        '        Add_Cell("N/A")
        '        Add_Cell("N/A")
        '    Catch ex As Exception
        '        Session("CurrentError") = ex.Message.ToString
        '        Session("ErrLink") = "close"
        '        Session("ErrLinkText") = "Close Window"
        '        Server.Transfer("AppError2.aspx")
        '    Finally
        '        dataReader.Close()
        '    End Try
        'End Sub

        'Private Function PadDate(ByVal strItem As String) As String
        '    If strItem.Length = 1 Then
        '        Return "0" & strItem
        '    Else
        '        Return strItem
        '    End If
        'End Function

        'Private Sub Add_New_Row(ByVal strValue As String)
        '    Dim rowCNT
        '    Dim colCNT

        '    Table1.Rows.Add(New TableRow)
        '    rowCNT = Table1.Rows.Count - 1
        '    Table1.Rows(rowCNT).Cells.Add(New TableCell)
        '    colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '    Table1.Rows(rowCNT).Cells(colCNT).Text = strValue
        '    Table1.Rows(rowCNT).Cells(colCNT).CssClass = "msg5b"
        'End Sub

        'Private Sub Add_Cell(ByVal strValue As String)
        '    Dim rowCNT
        '    Dim colCNT

        '    rowCNT = Table1.Rows.Count - 1
        '    Table1.Rows(rowCNT).Cells.Add(New TableCell)
        '    colCNT = Table1.Rows(rowCNT).Cells.Count - 1
        '    Table1.Rows(rowCNT).Cells(colCNT).Text = strValue
        '    Table1.Rows(rowCNT).Cells(colCNT).CssClass = "msg3"
        '    Table1.Rows(rowCNT).Cells(colCNT).HorizontalAlign = HorizontalAlign.Center
        'End Sub

        'Private Sub BuildValueColumns(ByRef TB1 As Table, ByVal intViewID As Integer)
        '    Dim i As Integer
        '    Dim strSQLa As String = ""
        '    Dim DataReader_a As OdbcDataReader
        '    Dim rCNT As Integer = TB1.Rows.Count
        '    Dim cCNT As Integer = TB1.Rows(rCNT - 1).Cells.Count
        '    Dim cnt As Integer = 1
        '    Dim intColNbr As Integer = 2
        '    Dim arrData(6) As Integer

        '    strSQLa = "Select c.event_nbr, c.event_desc, "
        '    strSQLa += "count(a.view_nbr) as Total_Views "
        '    strSQLa += "FROM " & strDB & ".gmr_activity_log_v As a "
        '    strSQLa += "RIGHT OUTER  JOIN " & strDB & ".gmr_events_v As c "
        '    strSQLa += "ON c.event_nbr = a.event_nbr "
        '    strSQLa += "and a.view_nbr = " & intViewID
        '    strSQLa += " " & strDateWhere
        '    strSQLa += " group by c.event_desc, c.event_nbr Order By c.event_nbr ASC"
        '    DataReader_a = objTDCall.drData(SchemaNM, sTDUserID, strSQLa, strTDError)

        '    Do While DataReader_a.Read
        '        arrData(DataReader_a.GetValue(0)) = DataReader_a.GetValue(2)
        '        cnt += 1
        '        If cnt = 6 Then Exit Do
        '    Loop

        '    For i = 1 To 5
        '        If arrData(i).ToString <> "" Then
        '            BuildColumn(TB1, intColNbr, arrData(i), intViewID)
        '        Else
        '            BuildColumn(TB1, intColNbr, 0, intViewID)
        '        End If
        '        cnt += 1
        '        intColNbr += 1
        '    Next
        '    DataReader_a.Close()
        'End Sub

        'Private Sub BuildColumn(ByRef TB1 As Table, ByVal intColNbr As Integer, ByVal intData As Integer, ByVal intView As Integer)
        '    Dim i As Integer
        '    Dim rCNT As Integer = TB1.Rows.Count
        '    Dim cCNT As Integer = TB1.Rows(rCNT - 1).Cells.Count

        '    TB1.Rows(rCNT - 1).Cells.Add(New TableCell)
        '    cCNT = Table1.Rows(rCNT - 1).Cells.Count
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).Text = intData
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).CssClass = "msg3"
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).HorizontalAlign = HorizontalAlign.Center
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).ID = "c" & intColNbr & "r" & intView
        'End Sub

        'Private Sub UniqueUsers(ByRef TB1 As Table, ByVal intViewID As Integer)
        '    Dim strSQLa As String
        '    Dim DataReader_a As OdbcDataReader
        '    Dim rCNT As Integer = TB1.Rows.Count
        '    Dim cCNT As Integer = TB1.Rows(rCNT - 1).Cells.Count

        '    strSQLa = "Select Count(Distinct GMR_USER_ID) "
        '    strSQLa += "From " & strDB & ".GMR_ACTIVITY_LOG_V "
        '    strSQLa += strDateWhere
        '    strSQLa += "And view_nbr = " & intViewID
        '    DataReader_a = objTDCall.drData(SchemaNM, sTDUserID, strSQLa, strTDError)
        '    strSQLa = ""

        '    TB1.Rows(rCNT - 1).Cells.Add(New TableCell)
        '    cCNT = Table1.Rows(rCNT - 1).Cells.Count
        '    If DataReader_a.Read Then
        '        TB1.Rows(rCNT - 1).Cells(cCNT - 1).Text = DataReader_a.GetValue(0)
        '    Else
        '        TB1.Rows(rCNT - 1).Cells(cCNT - 1).Text = 0
        '    End If
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).CssClass = "msg3"
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).HorizontalAlign = HorizontalAlign.Center
        '    TB1.Rows(rCNT - 1).Cells(cCNT - 1).ID = "c1r" & intViewID
        '    DataReader_a.Close()
        'End Sub

        'Private Function fnPopValue() As Integer
        '    Dim strSQLa As String = ""
        '    Dim DataReader_a As OdbcDataReader
        '    Dim intPopValue As Integer

        '    strSQLa = "SELECT Count(Event_Nbr) FROM " & strDB & ".GMR_ACTIVITY_LOG_V "
        '    strSQLa += strDateWhere
        '    strSQLa += "And EVENT_NBR = 6"

        '    DataReader_a = objTDCall.drData(SchemaNM, sTDUserID, strSQLa, strTDError)

        '    If DataReader_a.Read Then
        '        intPopValue = DataReader_a.GetValue(0)
        '    Else
        '        intPopValue = 0
        '    End If
        '    DataReader_a.Close()

        '    Return intPopValue
        'End Function

        'Private Sub RunProgressBar(ByVal strAdjType As String)
        '    Dim PBar As New PGBar
        '    Dim strMsg As String
        '    strMsg = "<div style='font-size:11px;text-align:center;color:white;background-color:#808CA2;padding-left:3px;padding-right:3px' colspan='2'>" & strAdjType & "</div>"
        '    strMsg += "<table border=0 width='265px'>"
        '    strMsg += "<tr><td align='right' width='14%'><img src='images/Bar_chart.gif'></td><td valign='middle' align='center' style='font-size:12px'>&nbsp;Please stand by while compiling statistics.This will take several minutes.</td></tr>"
        '    strMsg += "</table>"

        '    Dim strBar As String = PBar.BuildProgressBar(strMsg, "#808CA2", 2, 38)

        '    Response.Write(strBar)
        '    Response.Flush()
    End Sub
End Class

